GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute#48854
Open
shashbha14 wants to merge 2 commits intoapache:mainfrom
Open
GH-48832: [R] Fix crash with zero-length POSIXct tzone attribute#48854shashbha14 wants to merge 2 commits intoapache:mainfrom
shashbha14 wants to merge 2 commits intoapache:mainfrom
Conversation
Add safety check for empty tzone attribute in InferArrowTypeFromVector to prevent out-of-bounds access when handling zero-length POSIXct vectors.
…t/Ubuntu Added Development Tool Requirements section to cpp/development.rst documenting the required versions: - clang-format 14.0.6+ - pre-commit 2.17.0+ - Ubuntu 22.04 LTS+
jonkeane
requested changes
Jan 14, 2026
Member
jonkeane
left a comment
There was a problem hiding this comment.
Thanks for submitting the change. The devtooling documentation should go in a separate PR IMO.
Would you mind moving the tests to where we test other examples of POSIXct? The approach to solve it looks solid, but CI will determine if we are good.
Comment on lines
+18
to
+35
| test_that("zero-length POSIXct with empty tzone attribute handled safely", { | ||
| x <- as.POSIXct(character(0)) | ||
| attr(x, "tzone") <- character(0) | ||
|
|
||
| # Should not crash or error | ||
| expect_error(type(x), NA) | ||
|
|
||
| # Should default to no timezone (or empty string which effectively means local/no-tz behavior in arrow) | ||
| # When sys.timezone is picked up it might vary, but we just check it doesn't crash. | ||
| # If it picks up Sys.timezone(), checking exact equality might be flaky across environments if not mocked. | ||
| # So we primarily check for no error. | ||
|
|
||
| # Also check write_parquet survival | ||
| tf <- tempfile() | ||
| on.exit(unlink(tf)) | ||
| expect_error(write_parquet(data.frame(x = x), tf), NA) | ||
| expect_true(file.exists(tf)) | ||
| }) |
Member
There was a problem hiding this comment.
Would you mind putting this test in somewhere around
arrow/r/tests/testthat/test-Array.R
Lines 279 to 325 in 962d051
and possibly for the parquet section, put it somewhere near
arrow/r/tests/testthat/test-parquet.R
Lines 119 to 153 in 962d051
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Fixes crash when writing zero-length POSIXct vectors with empty tzone attributes to Parquet in R 4.5.2.
What changes are included in this PR?
Are these changes tested?
Yes, new test case reproduces the issue and verifies the fix.
Closes #48832